<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8">
    <title>达内商城学子登陆页面</title>
    <link rel="stylesheet" th:href="@{/asserts/css/bootstrap/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/asserts/css/font-awesome/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/asserts/css/Ionicons/ionicons.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/asserts/css/AdminLTE/AdminLTE.min.css}">
    <!-- iCheck -->
    <link rel="stylesheet" th:href="@{/asserts/css/iCheck/square/blue.css}">
</head>
<body>
<!-- 页面顶部-->
<header id="top">
    <div class="top">
        <img alt="" th:src="../../static.asserts/img/header/logo.png"/>
        <span>欢迎登录</span>
    </div>
</header>
<div id="container">
    <div class="rt" id="cover">

        <div class="txt">
            <p>登录学子商城
                <span>
                        <a href="regist.html">新用户注册</a>
                    </span>
            </p>
            <div class="text">
                <input id="uname" name="uname" placeholder="请输入您的用户名" required type="text">
                <span></span>
            </div>

            <div class="text">
                <input id="upwd" maxlength="15" minlength="6" name="upwd" placeholder="请输入您的密码" required
                       type="password">
                <span></span>
            </div>
            <div class="chose">

            </div>
            <input class="button_login" id="bt-login" type="button" value="登录"/>
        </div>
        </form>
    </div>
</div>
<!--错误提示-->
<div id="showResult"></div>
<!-- 品质保障，私人定制等-->
<div id="foot_box">
    <div class="icon1 lf">
        <img alt="" th:src="@{/asserts/img/footer/icon1.png}"/>

        <h3>品质保障</h3>
    </div>
    <div class="icon2 lf">
        <img alt="" th:src="@{/asserts/img/footer/icon2.png}"/>

        <h3>私人定制</h3>
    </div>
    <div class="icon3 lf">
        <img alt="" th:src="@{/asserts/img/footer/icon3.png}"/>

        <h3>学员特供</h3>
    </div>
    <div class="icon4 lf">
        <img alt="" th:src="@{/asserts/img/footer/icon4.png}"/>

        <h3>专属特权</h3>
    </div>
</div>
<!-- 页面底部-->
<div class="foot_bj">
    <div id="foot">
        <div class="lf">
            <p class="footer1"><img alt="" class=" footLogo" th:src="@{/asserts/img/footer/tedu.png}"/></p>
            <p class="footer2"><img alt="" th:src="@{/asserts/img/footer/footerFont.png}"/></p>
            <!-- 页面底部-备案号 #footer -->
            <div class="record">
                2001-2016 版权所有 京ICP证8000853号-56
            </div>
        </div>
        <div class="foot_left lf">
            <ul>
                <li><a href="#"><h3>买家帮助</h3></a></li>
                <li><a href="#">新手指南</a></li>
                <li><a href="#">服务保障</a></li>
                <li><a href="#">常见问题</a></li>
            </ul>
            <ul>
                <li><a href="#"><h3>商家帮助</h3></a></li>
                <li><a href="#">商家入驻</a></li>
                <li><a href="#">商家后台</a></li>
            </ul>
            <ul>
                <li><a href="#"><h3>关于我们</h3></a></li>
                <li><a href="#">关于达内</a></li>
                <li><a href="#">联系我们</a></li>
                <li>
                    <img alt="" th:src="@{/asserts/img/footer/wechat.png}"/>
                    <img alt="" th:src="@{/asserts/img/footer/sinablog.png}"/>
                </li>
            </ul>
        </div>
        <div class="service">
            <p>达内商城客户端</p>
            <img class="lf" th:src="@{/assertsimg/footer/ios.png}">
            <img alt="" class="lf" th:src="@{/asserts/img/footer/android.png}"/>
        </div>
        <div class="download">
            <img th:src="@{/asserts/img/footer/erweima.png}">
        </div>
    </div>
</div>
<script th:src="@{/asserts/js/jquery/jquery.min.js}"></script>
<script>
    $("#uname").blur(function () {
        var data = $("#uname").val();
        if (data == null || data == "") {
            $("#showResult").text("用户名不能为空！");
            $("#showResult").css("color", "red");
            return false;
        }
        $.ajax({
            type: "POST",
            url: "unameCheck.action",
            data: "uname=" + data,
            beforeSend: function (XMLHttpRequest) {
                $("#showResult").text("正在查询");

            },
            success: function (msg) {
                if (msg === "yes") {
                    $("#showResult").text("");
                } else if (msg === 'no') {
                    $("#showResult").text("该用户不存在");
                    $("#showResult").css("color", "red");
                }
            },
            error: function () {
                //错误处理
                $("#showResult").text("系统异常！");
                $("#showResult").css("color", "red");
            }
        });
    });
    $('#bt-login').click(function () {
        window.location.href = "index.html";
        //读取用户的输入——表单序列化
        var inputData = $('#fm-login').serialize();
        // alert(inputData);
        //异步提交请求，进行验证
        $.ajax({
            async: true,
            type: 'POST',
            url: 'login.action',
            data: inputData,
            success: function (txt, msg, xhr) {
                // alert("*"+txt+"*");
                if (txt == 'yes') {  //登录成功
                    var loginName = $('[name="uname"]').val();
                    console.log(loginName);
                    window.location.href = "index.html";
                } else { //登录失败
                    $('#showResult').html('登录失败！');
                }
            }
        });
    });
</script>
</body>
</html>
